<!DOCTYPE html>
<html lang=zh-cn">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>JS009-Math对象</title>
</head>
<style>
  th,
  td {
    border: 1px solid black;
    padding: 0 5px;
    text-align: center;
    font-size: 20px;
  }

  table {
    border-collapse: collapse;
  }
</style>

<body>
  <script>
    //floor, ceil, round
    let arr = [
      -1.1, -1.2, -1.3, -1.4, -1.49, -1.5,
      -1.51, -1.6, -1.7, -1.8, -1.9,

    ]
    document.writeln('<table>')
    document.writeln(`
      <tr>
        <th>Number</th>
        <th>Floor</th>
        <th>Ceil</th>
        <th>Round</th>
      </tr>
    `)
    for (let i = 0; i < arr.length; i++) {
      document.writeln(`
      <tr>
        <td>${arr[i]}</td>
        <td>${Math.floor(arr[i])}</td>
        <td>${Math.ceil(arr[i])}</td>
        <td>${Math.round(arr[i])}</td>
      </tr>
      `)
    }
    document.writeln('</table>')

    // random
    for (let i = 0; i < 200; i++) {
      document.writeln(getRandom(1, 100))
    }

    function getRandom(m, n) {
      return Math.floor(Math.random() * (n - m + 1)) + m
    }
  </script>
</body>

</html>